<?php
/**
 * Created by PhpStorm.
 * User: Guangpeng Chen
 * Date: 10-16/0016
 * Time: 14:50
 */

define('ROOT_PATH','/var/www/html/new/');
define('FX_PATH', ROOT_PATH.'d/class/');
$_ac = '16ucom';
$_pw = 'c33367701511b4f6020ec61ded352059';
//use pft\Prod\Sale\Price;

include FX_PATH . 'SoapInit.class.php';
include FX_PATH . 'Price.class.php';
include ROOT_PATH . 'conf/le.je';
$le = new go_sql();
$le->connect();


$soap = SoapInit::GetSoapInside();

$soap_16u = SoapInit::GetSoapFX();

$price = new Price(4048);
$date_today = date('Y-m-d');
///[综合]动态价格获取（产品ID，日期，模式[0XML 1单个价格2单个最低价]，开始时间，
//结束时间，类型[0供应价 1零售价]）说明：时间段价格$date,$mode必须为默认空值并会跨时间集
//$price_xml2 = $soap->get_Dynamic_Price_Merge(3481,$date_today, 0);
//echo $price_xml2;
//$sql = "SELECT l.title,l.apply_did,t.title as ttitle,t.pid from uu_land l left join uu_jq_ticket t on t.landid=l.id where t.id=4047";
//$GLOBALS['le']->query($sql);
//while($row=$GLOBALS['le']->fetch_assoc()) {
//    print_r($row);
//}
////$price_xml = $soap_16u->get_Dynamic_Price_Merge(3499,$date_today, 0);
//////$price_arr = simplexml_load_string($price_xml);
////echo $price_xml;
//$sql_rm = "DELETE FROM uu_product_price where id IN(7769,7768,7767)";
//$GLOBALS['le']->query($sql_rm);
//sleep(5);
//$price_xml2 = $soap->get_Dynamic_Price_Merge(1135, $date_today, 0);
//echo $price_xml2;
//exit;


$pft_rflex_id = 2339;// 闽清白岩山+先行酒店[普通票]
$pft_rflex_id = 3499;//  测试先行景区[成人票（平时）]


$pft_rflex_id = 1936;//


$pft_pid = 4047;
$pft_tid = 6959;
$xx_id  = 3499;

$price_xml = $soap_16u->get_Dynamic_Price_Merge($xx_id,$date_today, 0);
$price_arr = simplexml_load_string($price_xml);
//print_r($price_arr);
$price_xml2 = $soap->get_Dynamic_Price_Merge($pft_pid, $date_today, 0);
//$price_xml2 = $soap->get_Dynamic_Price_Merge(1135, $date_today, 0);
echo $price_xml2;
//exit;
foreach ($price_arr as $val) {
    $enddate = (string)$val->UUend_date;
    if($enddate < $date_today) continue;
    $rid   = (int)$val->UUid;
    $ptype = (int)$val->UUptype;
    $g_price = $ptype==1 ? (int)$val->UUs_price+100:(int)$val->UUn_price+100;
    $l_price = (int)$val->UUl_price+100;
    $ondays = (string)$val->UUweekdays;
    $startdate = (string)$val->UUstart_date;

    $storage = (int)$val->UUstorage;
//    echo $g_price , '---', $l_price;

    $ret = $soap->In_Dynamic_Price_Merge($pft_tid, $startdate,
        $enddate, $g_price, $l_price, $ptype, 2, $rid, '',
        $ondays, $storage, 11);
    echo <<<CODE
In_Dynamic_Price_Merge($pft_tid, $startdate,
$enddate, $g_price, $l_price, $ptype, 0, $rid, '',
$ondays, $storage);
CODE;

    echo '<code>' .$rid .'=>'. $ret . '</code>' . PHP_EOL;
}
/*
 * <code>17173=>142</code>
 * <code>17172=>142</code>
 * <code>17171=>100</code>
 */
//$res = $soap_16u->In_Dynamic_Price_Merge($pid, $startdate='', $enddate='', $g_price=0, $l_price=0, $ptype=0, $mode=0, $rid=0, $memo='', $ondays='', $storage='')
//$price_xml = $price->GetDynamicPrice($date_today);
//echo $price_xml;

echo PHP_EOL . 'AFTER UPDATED' . PHP_EOL;

$price_xml2 = $soap->get_Dynamic_Price_Merge($pft_pid,$date_today, 0);
echo $price_xml2;
